<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>登录日志管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function exports(){
			var size = $("#contentTable tbody tr").length;
			if(size>0){
				$("#exports").submit();
			}else{
				showTip("导出失败！没有需要导出的登录日志数据","",3000,0);
			}
		}
		function resetFunc(){
			$("#searchForm input[type='text']").val("");
			$('#s2id_userType').find('.select2-chosen').html('请选择');
			$("#userType").find("option")[0].selected='selected';
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/loginInfo/">登录日志列表</a></li>
	</ul>
	<form:form id="exports" modelAttribute="loginInfo" action="${ctx}/sys/loginInfo/export" method="post" >
		<input type="hidden" name="userType" value="${loginInfo.userType }"/>
		<input type="hidden" name="startTime" value="${loginInfo.startTime }"/>
		<input type="hidden" name="endTime" value="${loginInfo.endTime }"/>
		<input type="hidden" name="company" value="${loginInfo.company }"/>
	</form:form>
	<form:form id="searchForm" modelAttribute="loginInfo" action="${ctx}/sys/loginInfo/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li>
				<label>用户类型：</label>
				<form:select path="userType" class="input-medium">
			    <form:option value="" label="所有"/>
			    <form:options  items="${fns:getDictList('user_type')}" htmlEscape="false" itemValue="value" itemLabel="label"/>
			    </form:select>
			</li>
			<li>
				<label style="width:120px;">登录时间：</label>
				<input name="startTime" type="text" placeholder="开始时间" readonly="readonly" class="input-medium Wdate " 
			         value="<fmt:formatDate value="${loginInfo.startTime }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			         onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
			     -
			     <input name="endTime" type="text" placeholder="结束时间" readonly="readonly" class="input-medium Wdate " 
			     	value="<fmt:formatDate value="${loginInfo.endTime }" pattern="yyyy-MM-dd HH:mm:ss"/>"
			     	onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> 
			</li>
		</ul>
		<ul class="ul-form">
			<li>
				<label>企业名称：</label>
				<form:input path="company" htmlEscape="false" maxlength="40" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input class="btn btn-primary" type="button" value="重置" onclick="resetFunc()"/></li>
			<li class="btns"><input class="btn btn-primary" type="button" value="导出" onclick="exports()"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<div style="display:none;">
		<sys:message content="${message}"/>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th>序号</th>
			<th>用户类型</th>
			<th>用户名</th>
			<th>企业名称</th>
			<th>登录IP</th>
			<th>登录设备</th>
			<th>登录时间</th>
			<th>登录浏览器</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="loginInfo" varStatus="index">
			<tr>
				<td>${index.index+1 }</td>
				<td>${fns:getDictLabel(loginInfo.userType, 'user_type', '')}</td>
				<td>${loginInfo.loginName }</td>
				<c:choose>
				<c:when test="${loginInfo.userType==2 }">
					<td>${loginInfo.company }</td>
				</c:when>
				<c:otherwise>
					<td>--</td>
				</c:otherwise>
				</c:choose>
				<td>${loginInfo.loginIp }</td>
				<td>${loginInfo.equipment }</td>
				<td><fmt:formatDate value="${loginInfo.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				<td>${loginInfo.browserName }</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>